package libnetdb.dm.assoc.dhp.demo;

import java.io.*;
import java.util.*;

import libnetdb.dm.assoc.base.*;
import libnetdb.dm.assoc.dhp.*;
import libnetdb.dm.assoc.util.*;
public class DemoApp2 {

    private static void printUsage(PrintStream ps){
        ps.println("usage: filename support confidence");
    }

    public static void main(String argv[]) throws Exception{
        if(argv.length < 3){
            printUsage(System.err);
            System.exit(-1);
        }
        NameSpace ns = new BasicNameSpace();
        TextInput input = new TextInput(argv[0], ns);
        DirectBuilder output = new DirectBuilder();
        double support = Double.parseDouble(argv[1]);
        double confidence = Double.parseDouble(argv[2]);
        DHPMiner miner = new DHPMiner(input, output, support);
        miner.addProgressListener(new ConsoleMessenger());
        try {
            miner.run();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        RuleSet rs = output.getRuleSet();
		rs.setNameSpace(ns);
        Iterator it = rs.getRules(support,confidence);
		System.out.println("All Rules: ");
        while (it.hasNext()){
			Rule rule = (Rule) it.next();
		    System.out.print(rule.toString());
		    System.out.println();
        
        }
        
    }
}
